<?php if(count($records) > 0): ?>
<table>
  <thead>
    <tr>
  <?php foreach($records[0] as $key=>$val): ?>
      <th style="padding:5px 20px"><?php echo $key ?></th>
  <?php endforeach; ?>
    </tr>
  </thead>
  <tbody>
    <?php foreach($records as $record): ?>
    <tr>
        <?php foreach($record as $key=>$val): ?>
          <td style="padding:5px 20px"><?php echo $val ?></td>
        <?php endforeach; ?>
    </tr>
    <?php endforeach; ?>
  </tbody>
</table>
<?php else: ?>
<p>No records found for this user.</p>
<?php endif; ?>